package com.ruoyi.project.controller;

import java.util.List;

import com.ruoyi.project.domain.OrderInfo;
import com.ruoyi.project.service.OrderInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.BeamRealtime;
import com.ruoyi.project.domain.CurMachine;
import com.ruoyi.project.service.IBeamRealtimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实时数据Controller
 *
 * @author 向军
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/mes/realtime")
public class BeamRealtimeController extends BaseController
{
    @Autowired
    private IBeamRealtimeService beamRealtimeService;
    @Autowired
    private OrderInfoService orderInfoService;

    /**
     * 查询实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('mes:realtime:list')")
    @GetMapping("/list")
    public TableDataInfo list(BeamRealtime beamRealtime)
    {
        startPage();
        List<BeamRealtime> list = beamRealtimeService.selectBeamRealtimeList(beamRealtime);
        return getDataTable(list);
    }

    /**
     * 导出实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('mes:realtime:export')")
    @Log(title = "实时数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BeamRealtime beamRealtime)
    {
        List<BeamRealtime> list = beamRealtimeService.selectBeamRealtimeList(beamRealtime);
        ExcelUtil<BeamRealtime> util = new ExcelUtil<BeamRealtime>(BeamRealtime.class);
        return util.exportExcel(list, "实时数据数据");
    }

    /**
     * 获取实时数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:realtime:query')")
    @GetMapping(value = "/{mid}")
    public AjaxResult getInfo(@PathVariable("mid") String mid)
    {
        return AjaxResult.success(beamRealtimeService.selectBeamRealtimeByMid(mid));
    }

    /**
     * 新增实时数据
     */
    @PreAuthorize("@ss.hasPermi('mes:realtime:add')")
    @Log(title = "实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BeamRealtime beamRealtime)
    {
        return toAjax(beamRealtimeService.insertBeamRealtime(beamRealtime));
    }

    /**
     * 修改实时数据
     */
    @PreAuthorize("@ss.hasPermi('mes:realtime:edit')")
    @Log(title = "实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BeamRealtime beamRealtime)
    {
        return toAjax(beamRealtimeService.updateBeamRealtime(beamRealtime));
    }

    /**
     * 删除实时数据
     */
    @PreAuthorize("@ss.hasPermi('mes:realtime:remove')")
    @Log(title = "实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mids}")
    public AjaxResult remove(@PathVariable String[] mids)
    {
        return toAjax(beamRealtimeService.deleteBeamRealtimeByMids(mids));
    }
}
